package Homework;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class AddAll {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        System.out.println("c:"+c);



        Collection c2 = new ArrayList();
        c2.add("six");
        c2.add("seven");
        c2.add("eight");
        System.out.println("c2:"+c2);

        c.addAll(c2);
        System.out.println("c:"+c);
        System.out.println("c2:"+c2);


        Collection c3 = new ArrayList();
        c3.add("one");
        c3.add("two");
        c3.add("three");
        c3.add("four");
        c3.add("five");
        System.out.println("c3:"+c3);
        boolean contains = c3.containsAll(c);
        System.out.println(c);
        System.out.println(c3);

        Collection<String> c4 = new ArrayList<>();
        c4.add("one");
        c4.add("#");
        c4.add("two");
        c4.add("#");
        c4.add("three");
        c4.add("#");
        c4.add("four");
        c4.add("#");
        c4.add("five");
        System.out.println(c4);
        Iterator<String> iterator = c4.iterator();
        while (iterator.hasNext()){
            String str = iterator.next();
            if("#".equals(str)){
                iterator.remove();
            }
        }
        System.out.println(c4);




        String[] array = {"one","two","three","four","five"};
        for (String str:array){
            System.out.println(str);
        }



        Collection<String> c5 = new ArrayList<>();
        c5.add("one");
        c5.add("two");
        c5.add("three");
        c5.add("four");
        c5.add("five");
        for (String str:c5){
            System.out.println(str);
        }

        List<String> list = new ArrayList<>();
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        System.out.println(list);

        String s = list.get(2);
        System.out.println(s);
        for (int i = 0; i < list.size(); i++){
            System.out.println(list.get(i));
        }


        list.set(2, "six");
        System.out.println(list);


        list.add(2, "seven");
        System.out.println(list);

        list.remove(2);
        System.out.println(list);









































































































































































    }
}
